Socket
Socket
Sign inDemoInstall

index-to-position

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

index-to-position

Convert a string index to its line and column position


Version published
Weekly downloads
1.2M
increased by4.11%
Maintainers
1
Weekly downloads
 
Created
Source

index-to-position

Convert a string index to its line and column position

Install

npm install index-to-position

Usage

import indexToPosition from 'index-to-position';

indexToPosition('hello\nworld\n!', 7);
//=> {line: 1, column: 1}

API

indexToPosition(text, index, options?)

text

Type: string

The text in which to find the line and column position.

index

Type: number

The index in the string for which to find the line and column position.

options

Type: object

oneBased

Type: boolean
Default: false

Whether to use 1-based or 0-based indexing for the result.

Keywords

FAQs

Package last updated on 09 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc